const path = require('path')
const resolve = (dir) => {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath: './', //打包后的位置(如果不设置这个静态资源会报404)
  // publicPath: process.env.NODE_ENV === "production" ? "http://47.92.237.225:8080/dist" : "./",
  outputDir: 'dist', //打包后的目录名称
  assetsDir: 'static', //静态资源目录名称
  chainWebpack: (config) => {
    config.resolve.alias
      //set第一个参数：设置的别名，第二个参数：设置的路径
      .set('@', resolve('./src'))
      .set('components', resolve('./src/components'))
      .set('assets', resolve('./src/assets'))
      .set('views', resolve('./src/views'))
      .set('images', resolve('./src/assets/images'))
    //注意 store 和 router 没必要配置
  },
  devServer: {
    hot: true,
    port: 2000,
    open: true,
    noInfo: false,
    overlay: {
      warnings: true,
      errors: true,
    },
    proxy: {
      // 配置跨域
      '/api': {
        target: 'https://zwfw.szns.gov.cn/uauth', //后端接口地址
        ws: true,
        changOrigin: true,
        pathRewrite: {
          '^/api': '',
        },
      },
    },
  },
}
